<?php
  class Plugins_Contact extends model {
  
  function getformadd($productid="")
  {
  
  
  
  
//  $echo=1;
//  $str="";
//  $pertyalltime['class']="checkBoxDm";
//  $checkbox1=new Element_Checkbox("", "alltime[]", array("1" => ""),$pertyalltime);
//  $alltime=$checkbox1->render($echo);
  $alltime="<input type=\"checkbox\" class=\"checkBoxDm\" name=\"alltime[]\" value=\"1\">";
  
  
  
  
  
  
 // 
//  $arrayselect=$this->gettime();
//  $perty['class']="inpAddCtnt w120 clBg5 clBd2 fs03 clTxt2";
//  $perty['placeholder']="Open Hour";
//  $textbox1=new Element_Textbox("", "openhours[]",$perty);
//  $openhours=$textbox1->render($echo);
  
  $openhours='<input type="text" placeholder="Open Hour" class="inpAddCtnt w120 clBg5 clBd2 fs03 clTxt2" name="openhours[]" kl_virtual_keyboard_secure_input="on">';
  
  

  
 
  //$perty['class']="inpAddCtnt w120 clBg5 clBd2 fs03 clTxt2";
//  $perty['placeholder']="Close Hour";
//  $textbox1=new Element_Textbox("", "closehours[]",$perty);
//  $closehours=$textbox1->render($echo);
  
  $closehours='<input type="text" placeholder="Close Hour" class="inpAddCtnt w120 clBg5 clBd2 fs03 clTxt2" name="closehours[]" kl_virtual_keyboard_secure_input="on">';
  
  
  
   
  //$perty['class']='inpAddCtnt inpAddInfoPlg clBg5 clBd2 fs03 clTxt2';
//  $perty['placeholder']="Additional Information";
//  $textareabox1=new Element_Textarea("", "infomation[]",$perty);
//  $infomation=$textareabox1->render($echo);
  
  
  $infomation='<textarea placeholder="Additional Information" class="inpAddCtnt inpAddInfoPlg clBg5 clBd2 fs03 clTxt2" name="infomation[]"></textarea>';
  
  
   
//  $perty=array();
//  $perty['class']='checkBoxDm';
//  $checkbox1=new Element_Checkbox("", "sameaddressprofile[]", array($this->userdata['userid'] => ""),$perty);
//  $sameaddressprofile=$checkbox1->render($echo);
  
  $sameaddressprofile='<input type="checkbox" value="'.$this->userdata['userid'].'" class="checkBoxDm" name="sameaddressprofile[]" id="-0">';
  
  
  
 
  
  
  //$perty['class']='clBg5 clBd2 fs03 clTxt2';
//  $textareabox2=new Element_Textarea("", "address[]",$perty);
//  $address=$textareabox2->render($echo);
  
  
  $address='<textarea class="clBg5 clBd2 fs03 clTxt2" name="address[]"></textarea>';
  
  
  
  
  
  
  $datacountry['value']=210;
//  
   $arraycountry=$this->getcountry();
//  $option['0']="Please select Country";
//  if(count($arraycountry))
//  foreach($arraycountry as $keycountry=> $valuecountry)
//  $option[$keycountry]=$valuecountry;
  
  
  
   


  //$selectbox1=new Element_Select("", "countryid[]",$option,$datacountry);
//  $countryid=$selectbox1->render($echo);
  
  
  $countryid='<select name="countryid[]">';
   $countryid.="<option value=\"0\">Please select Country</option>";
   
     if(count($arraycountry))
     foreach($arraycountry as $keycountry=> $valuecountry)
     {
     if($keycountry=="210")
     {
     $countryid.="<option selected=\"\" value=\"$keycountry\">$valuecountry</option>";
     }else
     {
     
     $countryid.="<option value=\"$keycountry\">$valuecountry</option>";
     }
     
     
     }
     
   
   
   $countryid.="</select>";
  
  
  
  
  
  
  
  if($datacountry['value']==210)
  {
  
  
  $show1='style=" display:none;"';
  $show2='style=""';
  
  //$perty4['style']=" display:block;";
  
  }else
  {
  
  $show1='style=""';
  $show2='style=" display:none;"';
  
  }
  
  
  
  $arrayprovince=$this->getprovince();
  //$option=array();
//  $option['0']="Please select Province";
//  if(count($arrayprovince))
//  foreach($arrayprovince as $keycountry=> $valuecountry)
//  $option[$keycountry]=$valuecountry;
//    
//  $selectbox1=new Element_Select("", "proid[]",$option);
//  $province=$selectbox1->render($echo);
  
  
  
   $province='<select name="proid[]">';
   $province.="<option value=\"0\">Please select Province</option>";
   
     if(count($arrayprovince))
     foreach($arrayprovince as $keycountry=> $valuecountry)
     {
  
  
     
     $province.="<option value=\"$keycountry\">$valuecountry</option>";
 
     
     
     }
     
   
   
   $province.="</select>";
  
  
  
  
  
  
//  $option=array(); 
//  $option['0']="Please select district";
//  
//  $selectbox1=new Element_Select("", "disid[]",$option);
  //$district=$selectbox1->render($echo);
  $district='<select name="disid[]">';
  $district.="<option value=\"0\">Please select district</option>";
  $district.="</select>";
  
  
  
  
  
  
//  $option=array();
//  $option['0']="Please select sub district";
//  
//  $selectbox1=new Element_Select("", "tumid[]",$option);
//  $tumid=$selectbox1->render($echo);

$tumid='<select name="tumid[]">';
$tumid.="<option value=\"0\">Please select sub district</option>";
$tumid.="</select>";

  
  //$perty1=array();
//  $perty1['class']='inpPostCode clBg5 clBd2 fs03 clTxt2';
//  $textbox1=new Element_Textbox("", "state[]",$perty1);
//  $state=$textbox1->render($echo);
    $state='<input type="text" class="inpPostCode clBg5 clBd2 fs03 clTxt2" name="state[]" >';

  
  
//   $textbox2=new Element_Textbox("", "code[]",$perty1);
//  $code=$textbox2->render($echo);
  
    $code='<input type="text" class="inpPostCode clBg5 clBd2 fs03 clTxt2" name="code[]" >';
  
  
  
  
   
//  $perty1=array();
//  $perty1['class']='checkBoxDm';
//  $checkbox2=new Element_Checkbox("", "samecontactprofile[]", array($_COOKIE['userid'] => ""),$perty1);
//  $samecontactprofile=$checkbox2->render($echo);
  
  $samecontactprofile='<input type="checkbox" value="'.$this->userdata['userid'].'" class="checkBoxDm" name="samecontactprofile[]" >';
  
  
  
  
 
  
//  $perty1=array();
//  $perty1['class']='clBg5 clBd2 fs03 clTxt2';
//  $perty1['placeholder']='e.g. facebook.com/dmconnex';
//  $textbox2=new Element_Textbox("", "facebook[]",$perty1);
//  $facebook=$textbox2->render($echo);
  
  $facebook='<input type="text" placeholder="e.g. facebook.com/dmconnex" class="clBg5 clBd2 fs03 clTxt2" name="facebook[]" >';
  
//  $perty1=array();
//  $perty1['class']='clBg5 clBd2 fs03 clTxt2';
//  $perty1['placeholder']='e.g. plus.google.com/+dmconnex';
//  $textbox2=new Element_Textbox("", "twitter[]",$perty1);
//  $twitter=$textbox2->render($echo);
  
  $twitter='<input type="text" placeholder="e.g. twitter.com/+dmconnex" class="clBg5 clBd2 fs03 clTxt2" name="twitter[]" >';
  
//  $perty1=array();
//  $perty1['class']='clBg5 clBd2 fs03 clTxt2';
//  $perty1['placeholder']='e.g. plus.google.com/+dmconnex';
//  $textbox2=new Element_Textbox("", "googleplus[]",$perty1);
//  $googleplus=$textbox2->render($echo);
  
  $googleplus='<input type="text" placeholder="e.g. plus.google.com/+dmconnex" class="clBg5 clBd2 fs03 clTxt2" name="googleplus[]" >';
  
  
//  $perty1=array();
//  $perty1['class']='clBg5 clBd2 fs03 clTxt2';
//  $perty1['placeholder']='user@email.com';
//  $textbox2=new Element_Textbox("", "email[]",$perty1);
//  $email=$textbox2->render($echo);
  
  $email='<input type="text" placeholder="user@email.com" class="clBg5 clBd2 fs03 clTxt2" name="email[]" >';
  
 // $perty1=array();
//  $perty1['class']='clBg5 clBd2 fs03 clTxt2';
//  $perty1['placeholder']=baseinfo;
//  $textbox2=new Element_Textbox("", "website[]",$perty1);
//  $website=$textbox2->render($echo);
  
  $website='<input type="text" placeholder="http://new.thailandoneclick.com" class="clBg5 clBd2 fs03 clTxt2" name="website[]" >';
  
//  $perty1=array();
//  $perty1['class']='clBg5 clBd2 fs03 clTxt2';
//  $perty1['placeholder']="02-xxx-xxxx";
//  $textbox2=new Element_Textbox("", "phone[]",$perty1);
//  $phone=$textbox2->render($echo);
  
  $phone='<input type="text" placeholder="02-xxx-xxxx" class="clBg5 clBd2 fs03 clTxt2" name="phone[]" >';
  
  
  
//  $textbox2=new Element_Textbox("", "fax[]",$perty1);
//  $fax=$textbox2->render($echo);
  
  $fax='<input type="text" placeholder="02-xxx-xxxx" class="clBg5 clBd2 fs03 clTxt2" name="fax[]" >';
  
  
//  $perty1=array();
//  $perty1['class']='clBg5 clBd2 fs03 clTxt2';
//  $perty1['placeholder']="e.g. instragram@dmconnex";
//  $textareabox2=new Element_Textarea("", "etc[]",$perty1);
//  $etc=$textareabox2->render($echo);
  
  $etc='<textarea placeholder="e.g. instragram@dmconnex" class="clBg5 clBd2 fs03 clTxt2" name="etc[]"></textarea>';
  
  
  
   $str='     <div class="wrpPlg clBg5 clBd2 bdFull">
                    <div class="wrpOutAtcPlg">
                        <div class="wrpAtcPlg">
                            <span class="ico icoOri icoCtcPlg"></span>
                            <div class="spnAtcPlg clTxtW">
                                <span class="txtAtcPlg fs03">Contact</span>
                            </div>
                        </div>
                    </div>
                    <div class="wrpTl">
                        <div title="Close" class="btnIco closeTl clBd3 mgBtm10 deleterowbutton">
                            <span class="ico icoCloseTl"></span>
                        </div>
                    </div>
                    <form class="frmCtcPlg clTxt3 fs03">
                        <div class="wrpOpenTimeAdrs">    
                            <fieldset class="wrpOpenTime">
                                <div class="wrpHdInfoGen mgBtm10">
                                    <h2 class="fs04 clTxt2">Opening Times</h2>
                                      '.$alltime.'
                                    <label for="openTime" class="userSlctNone">24 hours</label><br>
                                </div>
                                <div class="wrpInpOpentime">
                                        '.$openhours.'
                                    <span class="toGen">to</span>
                                        '.$closehours.' <br>
                                        '.$infomation.'
                                </div>
                            </fieldset>
                            <fieldset class="wrpAdrsInfo">
                                <div class="wrpHdInfoGen mgBtm10">
                                    <h2 class="ttlFullPf clTxt2 fs04">Address</h2>
                                    '.$sameaddressprofile.'
                                    <label for="cbAdrs" class="userSlctNone">Same as your profile</label>
                                </div>
                                <table class="tbGenInfo tbAddCtnt clTxt3 fs03">
                                    <tbody><tr>
                                        <th>Street Address</th>
                                        <td>'.$address.'</td>
                                    </tr>
                                    <tr >
                                        <th>Country</th>
                                        <td>
                                            <div class="reDesign">
                                               '.$countryid.'
                                            </div>
                                        </td>
                                    </tr>
                                    <tr class="prothaiclass" '.$show2.' >
                                        <th>State / Province / Region</th>
                                        <td >
                                            <div class="reDesign">
                                              '.$province.'
                                            </div>
                                        </td>
                                    </tr>
                                    <tr class="prothaiclass" '.$show2.'>
                                        <th>District</th>
                                        <td>
                                            <div class="reDesign">
                                               '.$district.'
                                            </div>
                                        </td>
                                    </tr>
                                    <tr class="prothaiclass" '.$show2.' >
                                        <th>Sub District</th>
                                        <td>
                                            <div class="reDesign">
                                               '.$tumid.'
                                            </div>
                                        </td>
                                    </tr>
                                    <tr class="prootherclass" '.$show1.'>
                                        <th>State</th>
                                        <td>
                                            <div >
                                               '.$state.'
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>Postal Code</th>
                                        <td>
                                            '.$code.'
                                        </td>
                                    </tr>
                                </tbody></table>
                            </fieldset>
                        </div>
                        <fieldset class="wrpCtcInfo">
                            <div class="wrpHdInfoGen mgBtm10">
                                <h2 class="fs04 clTxt2">Contact</h2>
                                '.$samecontactprofile.'
                                <label for="cbCtc" class="userSlctNone">Same as your profile</label>
                            </div>
                            <table class="tbGenInfo tbAddCtnt clTxt3 fs03">
                                <tbody><tr>
                                    <th>Facebook</th>
                                    <td>'.$facebook.'</td>
                                </tr>
                                <tr>
                                    <th>Twitter</th>
                                    <td>'.$twitter.'</td>
                                </tr>
                                <tr>
                                    <th>Google+</th>
                                    <td>'.$googleplus.'</td>
                                </tr>
                                <tr>
                                    <th>Website</th>
                                    <td>'.$website.'</td>
                                </tr>
                                <tr>
                                    <th>Email</th>
                                    <td>'.$email.'</td>
                                </tr>
                                <tr>
                                    <th>Phone</th>
                                    <td>'.$phone.'</td>
                                </tr>
                                <tr>
                                    <th>Fax</th>
                                    <td>'.$fax.'</td>
                                </tr>
                                <tr>
                                    <th>ETC</th>
                                    <td>'.$etc.'</td>
                                </tr>
                            </tbody></table>
                        </fieldset>
                    </form>
                </div>';  
  
  
  
  
  $arraydata['form']=addslashes(str_replace(array("\r", "", "\r"), '', $str));
  //$arraydata['js']=pluginjsinfo.'/contact.js';
  
  return $arraydata;
  
  
  
  
  
  
  }
  function getformlanding($arraydata)
  {
$code = '<div class="ldIt wrpCtcLd clBg4">';
$code .= '<div class="wrpOpenTimeAdrs">';
if(($arraydata['openhours']!=""&&$arraydata['closehours']!="")||$arraydata['alltime'])
{
$code .= '<div class="wrpOpenTimeLd">';

$code .= '<div class="wrpHdInfoGen mgBtm10">';
$code .= '<h2 class="clTxt2 fs04">Opening Times</h2>';
$code .= '</div>';
$code .= '<div class="OpenTimeLd">';
if(($arraydata['openhours']!=""&&$arraydata['closehours']!="")&&$arraydata['alltime']=='0' )
{
$code .= '<span>'.$arraydata['openhours'].'</span>';
$code .= '<span class="clTxt2">to</span>';
$code .= '<span>'.$arraydata['closehours'].'</span><br>';

$code .= '<span>'.$arraydata['infomation'].'</span>';

}else
{
$code .= '<span>open 24 hours</span>';

}


//$code .= '<p>Closed on Sunday.</p>';
$code .= '</div>';

$code .= '</div>';
}

$code .= '<div class="wrpAdrsInfo wrpAdrsLd">';
$code .= '<div class="wrpHdInfoGen mgBtm10">';
$code .= '<h2 class="clTxt2 fs04">Address</h2>';
$code .= '</div>';
$dataaddress="";
if($arraydata['address'])
{
     $dataaddress=$arraydata['address'];

}

$datatumname="";
if($arraydata['tumname'])
{
     $datatumname=" ".$arraydata['tumname'];

}


$datadisname="";
if($arraydata['disname'])
{
     $datadisname=" ".$arraydata['disname'];

}

$dataproname="";
if($arraydata['proname'])
{
$dataproname=" ".$arraydata['proname'];

}

$datacode="";
if($arraydata['code'])
{
     $datacode=" ".$arraydata['code'];

}

$datacountryname="";
if($arraydata['countryname'])
{
     $datacountryname=" ".$arraydata['countryname'];

}

$datastate="";
if($arraydata['state'])
{
     $datastate=" "+$arraydata['state'];

}





if($arraydata['countryid']=="210")
{

$code .= '<p>'.$dataaddress.$datatumname.$datadisname.$dataproname.$datacode.$datacountryname.'</p>';

}else
{
$code .= '<p>'.$dataaddress.$datastate.$datacountryname.'</p>';

}

$code .= '</div>';
$code .= '</div>';
$code .= '<div class="wrpCtcInfo">';
$code .= '<div class="wrpHdInfoGen mgBtm10">';
$code .= '<h2 class="clTxt2 fs04">Contact</h2>';
$code .= '</div>';
$code .= '<table class="tbGenInfo tbCtcLd tbAddCtnt clTxt3 fs03">';

if($arraydata['samecontactprofile'])
{
$arraydata=$this->getuserbyuserid($arraydata['samecontactprofile'],',facebook,twitter,googleplus,website,email,phone,fax,etc');

}

if(strpos($arraydata['facebook'],"facebook")!==false)
{
$datafacebook=$arraydata['facebook'];
if(strpos($arraydata['facebook'],"http")===false)
{
$datafacebook="http://".$arraydata['facebook'];

}


$code .= '<tr>';
$code .= '<th>Facebook</th>';
$code .= '<td><a href="'.$datafacebook.'" target="_blank">'.$datafacebook.'</a></td>';
$code .= '</tr>';
}


if(strpos($arraydata['twitter'],"twitter")!==false)
{
$datatwitter=$arraydata['twitter'];

if(strpos($arraydata['twitter'],"http")===false)
{

    $datatwitter="http://".$arraydata['twitter'];

}

$code .= '<tr>';
$code .= '<th>Twitter </th>';
$code .= '<td><a href="'.$datatwitter.'" target="_blank">'.$datatwitter.'</a></td>';
$code .= '</tr>';
}

if(strpos($arraydata['googleplus'],"google")!==false)
{
$datatgoogleplus=$arraydata['googleplus'];
if(strpos($arraydata['googleplus'],"http")===false)
{
    $datatgoogleplus="http://"+$arraydata['googleplus'];

}

$code .= '<tr>';
$code .= '<th>Google+</th>';
$code .= '<td><a href="'.$datatgoogleplus.'" target="_blank" >'.$datatgoogleplus.'</a></td>';
$code .= '</tr>';

}
if($arraydata['website'])
{


$code .= '<tr>';
$code .= '<th>Website</th>';
$code .= '<td><a href="'.$arraydata['website'].'" target="_blank" >'.$arraydata['website'].'</a></td>';
$code .= '</tr>';

}
if($arraydata['email'])
{
if(filter_var($arraydata['email'], FILTER_VALIDATE_EMAIL))
{
$code .= '<tr>';
$code .= '<th>Email</th>';
$code .= '<td>'.$arraydata['email'].'</td>';
$code .= '</tr>';
}
}
if($arraydata['phone'])
{
$code .= '<tr>';
$code .= '<th>Phone</th>';
$code .= '<td>'.$arraydata['phone'].'</td>';
$code .= '</tr>';
}
if($arraydata['fax'])
{
$code .= '<tr>';
$code .= '<th>Fax</th>';
$code .= '<td>'.$arraydata['fax'].'</td>';
$code .= '</tr>';
}
if($arraydata['etc'])
{
$code .= '<tr>';
$code .= '<th>ETC</th>';
$code .= '<td>'.$arraydata['etc'].'</td>';
$code .= '</tr>';
}


$code .= '</table>';
$code .= '</div>';
$code .= '<div class="emtGen"></div>';
$code .= '</div>';

  $data['str']=$code;
  $data['target']='secondtarget';

return $data;
  
  
  }
  
  function getplugin($plugreid)
  {
  
  $sql="select * from tb_plugins_contact where plugreid=".$plugreid;
  $arrayplugin=$this->db->db_set_1recordrow($sql);
  if($arrayplugin['sameaddressprofile'])
  {
  $select="address,countryid,disid,tumid,proid,code";
  $where['userid']=$arrayplugin['sameaddressprofile'];
  $arrayplugin2= $this->getdatarow("tb_user",$select,$where,1);
  $arrayplugin['address']=$arrayplugin2['address'];
  $arrayplugin['countryid']=$arrayplugin2['countryid'];
  $arrayplugin['disid']=$arrayplugin2['disid'];
  $arrayplugin['tumid']=$arrayplugin2['tumid'];
  $arrayplugin['proid']=$arrayplugin2['proid'];
  $arrayplugin['code']=$arrayplugin2['code'];
  
  }
  $arrayplugin['alltime']=intval($arrayplugin['alltime']);
  
  

  $arrayplugin['countryname']="";
  if($arrayplugin['countryid'])
  {
  $where=array();
  $select="name";
  $where['countryid']=$arrayplugin['countryid'];
  $names=$this->getdatarow("tb_country",$select,$where,1);
  $arrayplugin['countryname']=$names['name'];
  }
 
  if($arrayplugin['countryid']!=210)
  {   
  $arrayplugin['proid']=0;
  $arrayplugin['disid']=0;
  $arrayplugin['tumid']=0;
  }
  
  $arrayplugin['proname']="";
  if($arrayplugin['proid'])
  {
  $where=array();
  $select="proname";
  $where['proid']=$arrayplugin['proid'];
  $names=$this->getdatarow("tb_province",$select,$where,1);
  $arrayplugin['proname']=$names['proname'];
  }
  
  $arrayplugin['disname']="";
  if($arrayplugin['disid'])
  {
  $where=array();
  $select="disname";
  $where['disid']=$arrayplugin['disid'];
  $names=$this->getdatarow("tb_district",$select,$where,1);
  $arrayplugin['disname']=$names['disname'];
  }
  
  $arrayplugin['tumname']="";
  if($arrayplugin['tumid'])
  {
  $where=array();
  $select="tumname";
  $where['tumid']=$arrayplugin['tumid'];
  $names=$this->getdatarow("tb_tumbon",$select,$where,1);
  $arrayplugin['tumname']=$names['tumname'];
  }
  
  
   
  
  
  if($arrayplugin['samecontactprofile'])
  {
  $where=array();
  $select="facebook,twitter,googleplus,email,website,phone,fax,etc";
  $where['userid']=$arrayplugin['samecontactprofile'];
  $arrayplugin2= $this->getdatarow("tb_user",$select,$where,1);
  

  
  $arrayplugin['facebook']=$arrayplugin2['facebook'];
  $arrayplugin['twitter']=$arrayplugin2['twitter'];
  $arrayplugin['googleplus']=$arrayplugin2['googleplus'];
  $arrayplugin['email']=$arrayplugin2['email'];
  $arrayplugin['website']=$arrayplugin2['website'];
  $arrayplugin['phone']=$arrayplugin2['phone'];
  $arrayplugin['fax']=$arrayplugin2['fax'];
  $arrayplugin['etc']=$arrayplugin2['etc'];
  

  
  }
  
  if($arrayplugin['facebook']=="")
  {
  $arrayplugin['facebook']="";
  }
  if($arrayplugin['twitter']=="")
  {
  $arrayplugin['twitter']="";
  }
  if($arrayplugin['googleplus']=="")
  {
  $arrayplugin['googleplus']="";
  }
  
  if($arrayplugin['email']=="")
  {
  
  $arrayplugin['email']="";
  }
  
  if($arrayplugin['website']=="")
  {
  
  $arrayplugin['website']="";
  }
  if($arrayplugin['phone']=="")
  {
  
  $arrayplugin['phone']="";
  }
  
  if($arrayplugin['fax']=="")
  {
  
  $arrayplugin['fax']="";
  }
  
   if($arrayplugin['etc']=="")
  {
  
  $arrayplugin['etc']="";
  }
  

  
  
  return $arrayplugin;

  
  }
  
  function saveplugin($arraydata,$productid,$plugreid)
  {
  
  $arraydata['productid']=$productid;
  $arraydata['plugreid']=$plugreid;
  $this->db->db_set($arraydata,'tb_plugins_contact');
  
              $sql=$this->db->getstringdata();
            
         $ar['test']= $sql;
         $this->db->db_set($ar,'tb_log');
  
  }
   
  
  
  }
?>
